<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page contentType="text/html;charset=UTF-8" %>
<%@ include file="/commons/taglibs.jsp" %>
<%@ taglib tagdir="/WEB-INF/tags/simpletable" prefix="simpletable"%>
<html>
  <head>
    <title>${appname}</title>
	<%@include file="../meta.jsp"%>
	<script src="${ctx}/includes/jquery.js" type="text/javascript"></script>
	<script src="${ctx}/includes/jquery.validate.js" type="text/javascript"></script>
	<script src="${ctx}/js/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
	<script src="${ctx}/includes/jquery.form.js" type="text/javascript"></script>
	<%-- 
	<script src="${ctx}/includes/formValidator.js" type="text/javascript"></script>
	<link type="text/css" rel="stylesheet" href="${ctx}/includes/style/validator.css"></link>
	--%>
	
	<script type="text/javascript">
		/*
		$(document).ready(function(){
			$.formValidator.initConfig({
				formid:"employeeDemand_add_form",
				onerror:function(msg){alert(msg)},
				onsuccess:function(){addEmployeeDemand();return false;}
			});
			
			$("#lb").formValidator({onshow:"请选择类别",defaultvalue:""}).inputValidator({min:1,onerror: "请选择类别!"}).defaultPassed();
			$("#zt").formValidator({onshow:"请填写标题",defaultvalue:""}).inputValidator({min:1,onerror: "请填写标题!"}).defaultPassed();
			$("#nr").formValidator({onshow:"请填写内容",defaultvalue:""}).inputValidator({min:1,onerror: "请填写内容!"}).defaultPassed();
			//$("#nr").formValidator({onshow:"请输入你的内容",defaultvalue:"请填写内容。"}).inputValidator({min:20,onerror:"你输入的内容长度不正确,请确认"});
		});
		*/
		$(function(){
			$("#employeeDemand_add_form").validate({   
				errorPlacement: function(error, element){
		            $(element).next('.field_notice').hide();
		            $(element).after(error);
		       },
			   success: function(label){   
			       label.addClass('right').text('OK!');
			   },
			   rules:   
			   {
			    	lb: {required : true},
	            	zt: {required : true},
	            	nr: {required : true}
			   },   
			   message:{
			   		lb: {required : '请选择类别'},
			    	zt: {required : '请填写标题'},
	            	nr: {required : '请输入你的内容'}
			   },
			   submitHandler: function() {
			   		addEmployeeDemand();
			   }
			});  
		});
	</script>
  </head>
  
  <body>
    <div class="Teg_body">
    	<%@include file="../header.jsp"%>
    	
    	<div class="Teg_content">
    		<div class="content_left i-pane" id="zhd_LeftPane" paneid="LeftPane">
    			<div class="m-second-menu-title">
	    			<span class="Head">员工诉求</span>
    			</div>
    			<div class="m-second-menu-ct ZHDAlignleft">
	    			<div class="accordion-3-container">
	    				<ul class="accordion-3">
	    					<li class="active"><div class="level-first"><a href="${ctx}/demand_add.do">填写诉求</a></div></li>
	    					<c:forEach items="${lbList}" var="listrow">
	    					<li ${listrow.id == lb?'class="active"':''}><div class="level-first"><a href="demand_search.do?lb=${listrow.id}">${listrow.name}</a></div></li>
	    					</c:forEach>
	    				</ul>
	    			</div>
    			</div>
    			
    			<%@include file="../leftmenu.jsp"%>
    		</div>
    		<div class="content_right">
    			<div class="second_breadcrumb">
    				<span class="current_position">您的当前位置：<a href="${ctx}">首页</a>></span><span><a href="${ctx}/demand_search.do" class="SkinObject">员工诉求</a></span>
    			</div>
    			<div class="content_ct i-pane" id="zhd_ContentPane" style="margin-top: 5px;">
    				<s:form action="/demand_save.do" method="post" id="employeeDemand_add_form">
    				<s:token/>
    				<table class="form-table">
    					<tr>
							<th>
								<span class="note_red">*</span>类别：
							</th>
							<td>
								<mytag:select id="lb" title="请输入类别" name="lb" sql="basedata" isSql="false" condition="46" dataType="Long" listKey="id" listValue="name" headerKey="" headerValue="请选择"/>
							</td>
						</tr>
    					<tr>
							<th>
								<span class="note_red">*</span>标题：
							</th>
							<td>
								<s:textfield key="zt" title="请输入名称标题" cssClass="form-txtinput" id="zt" size="20" maxlength="100" value="%{model.zt}"/>
							</td>
						</tr>
						<tr>
							<th><span class="note_red">*</span>诉求内容：</th>
							<td>
								<textarea rows="4" name="nr" id="nr" style="width: 500px;" title="请输入诉求内容"></textarea>
							</td>
						</tr>
					</table>
					<div class="win-btn-panel">
						<input class="btn-short" type="submit" name="subbtn" value="提交" title="点击提交员工诉求">
					</div>
					
    				</s:form>
    			</div>
    		</div>
    		<div class="clear"></div>
    	</div>
    	<%@include file="../bottom.jsp"%>
    </div>
  </body>
</html>
<script type="text/javascript">
function addEmployeeDemand(){
	/*
	var form = $("#employeeDemand_add_form");
	var f = form.serialize();
	jQuery.ajax({
	   	type:'post',	
	   	url:'demand_save.do',
	   	data:f,
	   	success:resultHandler,
	    error:resultHandler
	});
	*/
	$('#employeeDemand_add_form').ajaxSubmit(resultHandler);
}
function resultHandler(responseXML){
	var result = responseXML.getElementsByTagName("result")[0].firstChild.nodeValue;
	var message = responseXML.getElementsByTagName("error-message")[0].firstChild.nodeValue;
	var errorType = responseXML.getElementsByTagName("error-type")[0].firstChild.nodeValue;
	if(!eval(result)&&(errorType!=2)){
		alert(message);
	}
	else{
		var curDate = new Date(); 
		alert(message);
		location.replace("demand_add.do?timsStamp=" + curDate.getTime());
	}
}
</script>